package com.qfedu.course.controller;

import com.qfedu.course.entity.Course;
import com.qfedu.course.service.ICourseService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.nio.channels.Channel;
import java.util.List;

/**
 * <p>
 * 课程管理 前端控制器
 * </p>
 *
 * @author zhangsan
 * @since 2023-03-02
 */
@RestController
@RequestMapping("/qf/course/")
public class CourseController extends BaseController {

    @Autowired
    ICourseService courseService;

    @RequiresPermissions("qf:course:list")
    @GetMapping("/list")
    public TableDataInfo list(){
        startPage();
          List<Course> list= courseService.getlist();
          return getDataTable(list);
    }


    /**
     * 添加课程
     */
    @PostMapping
    public AjaxResult addCourse(@RequestBody Course course){
        return  courseService.addCourse(course);
    }


    /**
     *删除课程
     */

    @RequiresPermissions("qf:course:DeleteCourse")
    @DeleteMapping("/{courseids}")
    public AjaxResult DeleteCourse(@PathVariable Long[] courseids){
        return courseService.DeleteCourse(courseids);

    }


    public  AjaxResult deleteUser(@PathVariable String add ){
        return  courseService.Deleteuser(add);
    }





}
